package com.fare.taluo.core.domain.queue.warn.repository.impl;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.dayatang.domain.QuerySettings;
import com.dayatang.hibernate.EntityRepositoryHibernate;
import com.fare.taluo.GlobalsConst;
import com.fare.taluo.core.domain.queue.warn.QueueFreightPriceWarnEntity;
import com.fare.taluo.core.domain.queue.warn.repository.QueueFreightPriceWarnReposity;
import com.foreveross.threadpool.queue.WorkQueue;
@Repository
public class QueueFreightPriceWarnReposityImpl extends
		EntityRepositoryHibernate implements QueueFreightPriceWarnReposity {

	@Override
	public List<QueueFreightPriceWarnEntity> listPlanStartEntity(int maxSize) {
		return super.find(QuerySettings.create(QueueFreightPriceWarnEntity.class).lt("planStartTime", new Date())
				.eq("status", WorkQueue.STATUS_WAITING).asc("createTime").setMaxResults(maxSize));
	}

	@Override
	public void deleteWait(Long id) {
		List<QueueFreightPriceWarnEntity> list = super.find(QuerySettings.create(QueueFreightPriceWarnEntity.class).eq("delegateId", id)
				.eq("status", WorkQueue.STATUS_WAITING).asc("createTime"));
		for(QueueFreightPriceWarnEntity e : list){
			e.setFlgDeleted(GlobalsConst.FLG_YES);
			this.save(e);
		}
	}
}
